home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 16 / interval.fth < prev    next >
Text File  |  1985-11-19  |  1KB  |  31 lines

  1. \ Attempt to rationally (is that possible?) deal with time intervals
  2.  
  3. hex
  4.  
  5. \ This variable counts the number of 5 msec timer ticks
  6. \ The manual says that this variable is at 4bc but it's really
  7. \ at 4ba on my system
  8. : get-ticks ( -- timer-ticks )  4ba l@  ;
  9.  
  10. 5 constant ms/tick ( -- n )
  11. td 1000  ms/tick  /  constant ticks/second ( -- ) 
  12.  
  13. \ This is not done with the existing comparison operators because
  14. \ we want to allow arbitrary crossings of the positive-to-negative
  15. \ boundaries of the number circle
  16. : reached? ( target -- ticks>=target? )
  17.    get-ticks - 0<
  18. ;
  19. : ms ( n -- ) \ Delay for at least n milliseconds
  20.    ms/tick /     ( #ticks )
  21.    1+            \ Delay at least 1 tick
  22.    get-ticks +   ( target )
  23.    begin  pause  dup reached?  until
  24.    drop
  25. ;
  26. -index  ( -- )  \ filename
  27.    reading
  28.    index /index th ff fill
  29.    last-char off
  30.    begin 1line  until
  31.